<?php

/*

cmsMethod: TracingMenu  <is:method call="TracingMenu" params="separator=' &gt; '&linkclass='classname'&posopen='&lt;b&gt;'&posclose='&lt;/b&gt;'" />

*/

require_once($GLOBALS['cfgPaths']['lib']."cms/cmsMethod.o.inc.php");

class tracingmenu extends cmsMethod
{

  // $params:: separator; linkclass; posopen; posclose; pos-> derzeitige Seite wird von posopen und posclose umschlossen
  function performAction ($params)
  {
    global $docs,$tpl,$env;
    if (!isset($params['separator'])) $params['separator'] = '';
    if (!isset($params['linkclass'])) $params['linkclass'] = '';
    if (!isset($params['posopen'])) $params['posopen'] = '';
    if (!isset($params['posclose'])) $params['posclose'] = '';
    $output = '';
    $pathArray = $docs->extractPathArray($this->doc_id,'id',true);
    if ($this->buildMode=='cache')
    {
        $home_id = $this->dba->getSitePubHomeId($GLOBALS['site_id']);
    }
    elseif (($this->buildMode=='export') || ($this->buildMode=='print'))
    {
        $home_id = $this->dba->getSitePubHomeId($env->getSession('s_currentSite'));
    }
    else {
        $home_id = $this->dba->getSiteHomeId($GLOBALS['is_live']?$GLOBALS['site_id']:$env->getSession('s_currentSite'));
    }
    if ($pathArray[0]!=$home_id)
      array_unshift($pathArray,$home_id);
    $count = count($pathArray);
    $params['posopen']  = $this->transEntities($params['posopen']);
    $params['posclose'] = $this->transEntities($params['posclose']);
    for ($i=0;$i<$count;$i++)
    {
       $doc = $docs->getById($pathArray[$i]);
       if ($doc['type']=='folder') continue;
       if ($pathArray[$i]==$this->doc_id)
       {
         $current = $docs->getByID($pathArray[$i]);
         $output .= $params['posopen'];
         $output .= ($current['descr'])?$current['descr']:$current['name'];
         $output .= $params['posclose'];
         $output .= ($i<($count-1))?$params['separator']:'';
       }
       else
       {
         $current = $docs->getByID($pathArray[$i]);
         $output .= '<a href="'.$tpl->prepareLink('pageid:'.$current['id']).'"';
         $output .= (!empty($params['linkclass']))?' class="'.$params['linkclass'].'"':'';
         $output .= '>';
         $output .= (!empty($current['descr']))?$current['descr']:$current['name'];
         $output .= '</a>';
         $output .= ($i<($count-1))?$params['separator']:'';
       }
       $this->registerRelation($pathArray[$i]);
    }
    return $output;
  }

}

?>